J (Programming Language)
:"The J programming language, developed in the early 1990s by Kenneth E. Iverson and Roger Hui, is a synthesis of APL (also by Iverson) and the FP and FL function-level languages created by John Backus. :To avoid repeating the APL special-character problem, J uses only the basic ASCII character set, resorting to the use of the dot and colon as inflections to form short words similar to digraphs. Most such primary (or primitive) J words serve as mathematical symbols, with the dot or colon extending the meaning of the basic characters available. Also, many characters which in other languages often must be paired (such as [] {} "" `` or <>) are treated by J as stand-alone words or, when inflected, as single-character roots of multi-character words. :J is a very terse array programming language, and is most suited to mathematical and statistical programming, especially when performing operations on matrices. It has also been used in extreme programming and network performance analysis. :Like the original FP/FL languages, J supports function-level programming via its tacit programming features. :Unlike most languages that support object-oriented programming, J's flexible hierarchical namespace scheme (where every name exists in a specific locale) can be effectively used as a framework for both class-based and prototype-based object-oriented programming. :Since March 2011, J is free and open-source software under the GNU General Public License version 3 (GPLv3)." * *K (programming language) – another APL-influenced language *Q – The language of KDB+ and a new merged version of K and KSQL. Try it Online! J compiler Overview :"J is a high-level, general-purpose programming language that is particularly suited to the mathematical, statistical, and logical analysis of data. It is a powerful tool for developing algorithms and exploring problems that are not already well understood. :J is written in portable C and is available for Windows, Linux, Mac, iOS, Android and Raspberry Pi. J can be installed and distributed for free. The source is provided under both commercial and GPL 3 licenses. :J is easy to install, has a small footprint, and has direct access to tutorials and documentation." :"Jd ( J database) is a high-performance columnar RDBMS written in J that is geared toward storing and analyzing large amounts of data. Jd is free for non-commercial use. :Jd lives openly and dynamically in the J execution and development environment, so that the full power of J is available to the application developer. For example, Jd columns are mapped to J nouns, so built-in J primitives can apply directly to the data. :It works well with large tables (millions of rows to billions), multiple tables connected by joins, structured data, numerical data, and complex queries and aggregations." Learning J |Math.yorku.ca:/Richard L.W. Brown/Optimization with J> |cs.Trinity.edu:/John E. Howland/Functional Programming and the J Programming Language> (#jsoftware IRC channel on freenode, registration info) Installation :"These instructions install a full system (base plus all addons) in the default location, for Windows or Mac." Structure Vocabulary :"J's documentation includes a dictionary, with words in J identified as nouns, verbs, modifiers, and so on. Primary words are listed in the vocabulary, in which their respective parts of speech are indicated using markup. Note that verbs have two forms: monadic (arguments only on the right) and dyadic (arguments on the left and on the right). For example, in '-1' the hyphen is a monadic verb, and in '3-2' the hyphen is a dyadic verb. The monadic definition is mostly independent of the dyadic definition, regardless of whether the verb is a primitive verb or a derived verb." : Data types and structures :"J supports three simple types: :* Numeric :* Literal (Character) :* Boxed :Of these, numeric has the most variants. :One of J's numeric types is the bit. There are two bit values: 0'', and ''1. Also, bits can be formed into lists. For example, 1 0 1 0 1 1 0 0 is a list of eight bits. Syntactically, the J parser treats that as one word. (The space character is recognized as a word-forming character between what would otherwise be numeric words.) Lists of arbitrary length are supported. :Further, J supports all the usual binary operations on these lists, such as and, or, exclusive or, rotate, shift, not, etc."" :"J also supports higher order arrays of bits. They can be formed into two-dimensional, three-dimensional, etc. arrays. The above operations perform equally well on these arrays. :Other numeric types include integer (e.g., 3, 42), floating point (3.14, 8.8e22), complex (0j1, 2.5j3e88), extended precision integer (12345678901234567890x), and (extended precision) rational fraction (1r2, 3r4). As with bits, these can be formed into lists or arbitrarily dimensioned arrays. As with bits, operations are performed on all numbers in an array. :Lists of bits can be converted to integer using the #. verb. Integers can be converted to lists of bits using the #: verb. (When parsing J, . (period) and : (colon) are word-forming characters. They are never tokens alone, unless preceded by whitespace characters.) :J also supports the literal (character) type. Literals are enclosed in quotes, for example, 'a' or 'b'. Lists of literals are also supported using the usual convention of putting multiple characters in quotes, such as 'abcdefg'. Typically, individual literals are 8-bits wide (ASCII), but J also supports other literals (Unicode). Numeric and boolean operations are not supported on literals, but collection-oriented operations (such as rotate) are supported. :Finally, there is a boxed data type. Typically, data is put in a box using the < operation (with no left argument; if there's a left argument, this would be the less than operation). This is analogous to C's & operation (with no left argument). However, where the result of C's & has reference semantics, the result of J's < has value semantics. In other words, < is a function and it produces a result. The result has 0 dimensions, regardless of the structure of the contained data. From the viewpoint of a J programmer, < puts the data into a box and allows working with an array of boxes (it can be assembled with other boxes, and/or more copies can be made of the box). Control structures :"J provides control structures (details here) similar to other procedural languages. Prominent control words in each category include: * assert. * break. * continue. * for. * goto_label. * if. else. elseif. * return. * select. case. * throw. * try. catch. * while. whilst." Glossary (see also Category:Programming#Programming Languages) Object-oriented programming :"Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data, in the form of fields (often known as attributes or properties), and code, in the form of procedures (often known as methods). A feature of objects is an object's procedures that can access and often modify the data fields of the object with which they are associated (objects have a notion of "this" or "self"). In OOP, computer programs are designed by making them out of objects that interact with one another. OOP languages are diverse, but the most popular ones are class-based, meaning that objects are instances of classes, which also determine their types. :Many of the most widely used programming languages (such as C++, Java, Python, etc.) are multi-paradigm and they support object-oriented programming to a greater or lesser degree, typically in combination with imperative, procedural programming. Significant object-oriented languages include Java, C++, C#, Python, PHP, JavaScript, Ruby, Perl, Object Pascal, Objective-C, Dart, Swift, Scala, Common Lisp, MATLAB, and Smalltalk." |Jsoftware.com://Chapter 25: Object-Oriented Programming> - Tutorial :"The combination of some data and some dedicated functions is called an object. Every object belongs to some specific class of similar objects. We will say that a stack is an object of the Stack class. :The dedicated functions for objects of a given class are called the "methods" of the class. For example, for objects of the Stack class we will need a method for adding a new item, and a method for retrieving the last-added item. :An object needs one or more variables to represent its data. Such variables are called fields. Thus for a stack we may choose to have a single field, a list of items. :In summary, OOP consists of identifying a useful class of objects, and then defining the class by defining methods and fields, and then using the methods. :By organizing a program into the definitions of different classes, OOP can be viewed as a way of managing complexity. The simple examples which follow are meant to illustrate the machinery of the OOP approach, but not to provide much by way of motivation for OOP." Class-based programming :"Class-based programming, or more commonly class-orientation, is a style of Object-oriented programming (OOP) in which inheritance occurs via defining classes of objects, instead of inheritance occurring via the objects alone (compare prototype-based programming). :The most popular and developed model of OOP is a class-based model, instead of an object-based model. In this model, objects are entities that combine state (i.e., data), behavior (i.e., procedures, or methods) and identity (unique existence among all other objects). The structure and behavior of an object are defined by a class, which is a definition, or blueprint, of all objects of a specific type. An object must be explicitly created based on a class and an object thus created is considered to be an instance of that class." :"Although Simula introduced the class abstraction, the canonical example of a class-based language is Smalltalk. Others include PHP, C++, Java, C#, and Objective-C." Prototype-based programming :"Prototype-based programming is a style of object-oriented programming in which behaviour reuse (known as inheritance) is performed via a process of reusing existing objects via delegation that serve as prototypes. This model can also be known as prototypal, prototype-oriented, classless, or instance-based programming. Delegation is the language feature that supports prototype-based programming. :Prototype-based programming uses generalized objects, which can then be cloned and extended. Using fruit as an example, a "fruit" object would represent the properties and functionality of fruit in general. A "banana" object would be cloned from the "fruit" object and general properties specific to bananas would be appended. Each individual "banana" object would be cloned from the generic "banana" object. Compare to the class-based paradigm, where a "fruit" class would be extended by a "banana" class. :The first prototype-oriented programming language was Self, developed by David Ungar and Randall Smith in the mid-1980s to research topics in object-oriented language design. Since the late 1990s, the classless paradigm has grown increasingly popular.needed Some current prototype-oriented languages are JavaScript (and other ECMAScript implementations such as JScript and Flash's ActionScript 1.0), Lua, Cecil, NewtonScript, Io, Ioke, MOO, REBOL and AHK." Tacit programming :"Tacit programming, also called point-free style, is a programming paradigm in which function definitions do not identify the arguments (or "points") on which they operate. Instead the definitions merely compose other functions, among which are combinators that manipulate the arguments. Tacit programming is of theoretical interest, because the strict use of composition results in programs that are well adapted for equational reasoning. It is also the natural style of certain programming languages, including APL and its derivatives, and concatenative languages such as Forth. The lack of argument naming gives point-free style a reputation of being unnecessarily obscure, hence the epithet "pointless style"." :"For example, a sequence of operations in an applicative language such as the following Python code: def example(x): y = foo(x) z = bar(y) w = baz(z) return w :... is written in point-free style as the composition of a sequence of functions, without parameters: ... example = compose(baz, bar, foo) Example Uses :"Historically, APL used / to indicate the fold, so +/1 2 3 was equivalent to 1+2+3. Meanwhile, division was represented with the classic mathematical division symbol (the obelus, ÷), which was implemented by overstriking a minus sign and a colon (on both EBCDIC and ASCII paper text terminals). Because ASCII in general does not support overstrikes in a device-independent way, and does not include a division symbol per se, J uses % to represent division, as a visual approximation or reminder. (This illustrates something of the mnemonic character of J's tokens, and some of the quandaries imposed by the use of ASCII.) :Defining a J function named avg to calculate the average of a list of numbers yields: avg=: +/ % #" :This is a test execution of the function: avg 1 2 3 4 :2.5 :# counts the number of items in the array. +/ sums the items of the array. % divides the sum by the number of items. Above, avg is defined using a train of three verbs (+/, %, and #) termed a fork. Specifically (V0 V1 V2) Ny is the same as (V0(Ny)) V1 (V2(Ny)) which shows some of the power of J. (Here V0, V1, and V2 denote verbs and Ny denotes a noun.) Mathematics *"Fibonacci sequence: 1{"1+/\@|.^:(i.20) 0 1 *Fibonacci sequence: }.(%-.-*:)t.i.20x (using Taylor coefficients) *Longest word(s) in a word list: w {~I.a=>./a=:># each w=:LF cut fread '/usr/share/dict/words' *Longest word(s) in a word list: w{~I.a=>./a=:>#each w=:'b' fread '/usr/share/dict/words' *Primes: x#~-.x e.~.,(x*/x=:2}.i.100) (inefficient) *Primes: (-.x e.~.,(x*/x))#x=:2}.i.100 (inefficient) *Primes: x#~1=+/0=(x|/x=:2}.i.100) (inefficient) *Primes: 2+I.1=+/0=x|/x=.2}.i.100 (inefficient) *Primes: ff=.13 : '*/*2}.(i.y)|y' *2}.I.>(ff each i.100) *Primes: p:i.20 (very efficient) *Euler totient function: >(13 : '+/1=x+.>:i.x') *Euler totient function: >5 p: (built-in) *Josephus (step f size): (13 : '1(x|.}.)^:(a)a=:i.y') *Finding the "inverse" of factorial: (!^:_1)120 *Rolling substrings: 3 : '(y+i.3) { abcdefghijkl' each i.10 *Which words (in word list w) are sorted?: ((w=(w/:&.>w))#w) *Which words are sorted (variant)?: ((w=(/:~&.>w))#w) *Which words are palindroms : (w=(|.&.>w))#w *Sort words according to length: (\: #&.>w){w" load'viewmat' (0,?$~99 3)viewmat+/2<|(j./~i:2j479)(+*:) ::(3:)"0^:(i.99)0 l=:(]=3+4=*)[:+/. :"The l=: on the left (that's a lowercase L) is the assignment (=:) of an operator (everything to the right) to the variable l. Couple of notes: #J code is evaluated strictly right to left unless there are parentheses, so we start on the right and work our way left. #Operators consist of most valid printable ASCII characters, or those characters and then a period or a colon." :"Okay, starting from the right: &|. :|. is the operator used to rotate a matrix along its axes (https://code.jsoftware.com/wiki/Vocabulary/bardot#dyadic), and & binds the thing on the left in parentheses, which will be a list of pairs of numbers, as the de facto left argument of the operator, which will tell it how to shift around the matrix of ones and zeros (the current state of the Life world) it's expecting as its right argument. (,"0/~@i:1) :Since this is in parentheses, it is evaluated before the rest of the code and forms its own unit. i: returns the integer counting vector symmetric about zero up to its argument 1, so _1 0 1. The @ pipes the output of that to the left unchanged, and ,"0/~ returns the Cartesian product of its argument over (in this case) the concatenation operator ,, with the result being a matrix of every possible combination of pairs of -1, 0, and 1. These are what are used to shift the incoming argument matrix of zeros and ones that represent the current state of the Life world. :Now, we have nine copies of the current Life world, shifted NW, N, NE, W, E, SW, S, SE, with the last being shifted by 0 0 and so being a direct copy of the original. Now, we add them all together with [:+/^:2 :Because it's a 2D matrix of matrices, we have to sum (+/) twice (^:2), once over rows and once over columns. The result is a matrix of the same size as the original Life world, in which each number represents the number of living cells (or 1's) at and around that location on the board. (=3+4=*) :The final piece is an application of the actual rules of Conway's Game of Life, those being: :When the sum of live cells at and around a cell is 3 (]=3), that cell is alive in the next round. :When the cell itself is alive * and it is surrounded by exactly 3 other live cells, that cell is alive in the next round (4=*). :These are added together with the + to form the resulting matrix, which represents the state of the Life world in the next round." Financial Analysis |news.ycombinator.com://The Q Language (kx.com)> by callinyouin (article on Q :"coliveira on Dec 12, 2017 - :J language is also an open source APL-derivative and offers similar features. ::throwaway7645 on Dec 13, 2017 - ::Also important to note is that J is the final language from the inventor of APL (Ken Iverson) who also got the Turing award for APL. J has some advancements from vanilla APL & doesn't require a special keyboard or symbols. Some of these new features were added to Dyalog APL (modern APL with good support). Roger Hui is a well known figure in the APL community. He helped write J and works for Dyalog APL :::beagle3 on Dec 13, 2017 - :::.... and the J implementation is inspired by the "A" miniature APL interpreter written by Arthur Whitney who later went to create K. See http://code.jsoftware.com/wiki/Essays/Incunabulum for more (and google "J incunabulum" if you want to see other people's commentaries)" |Quant.stackexchange.com:/Louis Marascio (2011)/Can the J language be used as an effective alternative to Q/Kdb+?> :|U://chrisaycock> :"You are right that the database component is the main selling point of q/kdb+. Indeed, many Kx customers use kdb+ just for time-series data (and often just for tick history) and don't take advantage of the q language. So the first disadvantage to using J as-is would be to miss the reason most folks even bother with Kx: data storage. :Now of course you could clone the data storage for J, just as you could for any language. The really hard part is coming-up with your own version of the query and join routines found in q.k, that cryptic file that comes with the q software distribution. :Regarding JDB, the biggest difference I can find is that it doesn't support partitioning. For example, kdb+ can split the column-mapped files into separate directories for each date. That means a query select from quotes where date=2011.09.08 will cause kdb+ to jump directly to today's ticks. Taking that further, kdb+ supports threading to some degree (via par.txt) so that it can process multiple dates in parallel. And beyond the performance benefits, partitioning is practically required for really large tables anyway since the columns are memory-mapped at query time; there's no feasible way to do that for a multi-terabyte database without some selectivity. :The second disadvantage is that there aren't nearly as many finance shops that use J. Almost every big bank has a Kx license somewhere, so there's always an expert if needed. J doesn't have nearly that adoption." Related Links *"APL :Created by Kenneth Iverson as the original array programming language. Uses a non-ASCII character set as there are no reserved words. The British APL Association keeps an up-to-date list of interpreters (both free and commercial) as well as information on the APL-inspired languages covered below. *A+ :Created by Arthur Whitney as a follow-up to APL. The source code is available under GPL and there is an included XEmacs extension. Download from the website. *J :Created by Kenneth Iverson and Roger Hui, this only requires ASCII characters. The source used to cost money, though recently was released under GPL. Download from the website. *K :Another Arthur Whitney language, this also uses ASCII characters. The company behind it has since decommissioned the language, but there is the open-source Kona. *Q :Built on top of K to include SQL-like query/join capabilities (tables are a built-in container), this language is built on handling lots of data. A non-commercial licensed version can be downloaded from the website." :"At the heart of Dyalog is an ISO/IEC 13751-compliant APL language engine that has been tuned and optimised for more than 30 years. The current Dyalog language has evolved from a classical APL2-style interpreter into a modern, multi-paradigm programming language. The most important extensions to the original APL language include:" R (Programming Language) :"R is a programming language and free software environment for statistical computing and graphics supported by the R Foundation for Statistical Computing. The R language is widely used among statisticians and data miners for developing statistical software and data analysis. Polls, data mining surveys, and studies of scholarly literature databases show substantial increases in popularity; as of July 2019, R ranks 20th in the TIOBE index, a measure of popularity of programming languages. :A GNU package, source code for the R software environment is written primarily in C, Fortran and R itself, and is freely available under the GNU General Public License. Pre-compiled binary versions are provided for various operating systems. Although R has a command line interface, there are several graphical user interfaces, such as RStudio, an integrated development environment." *"J :*strong mathematical focus :*conceptual framework for working with array data is very general, consistent and well thought out. :*code is succinct/terse :*object-oriented paradigm available but optional *R :*strong statistical focus :*object-oriented paradigm is pervasive :*mature/powerful plotting and graphics :*larger user base :*many user-contributed packages available :*syntax for entering/manipulating arrays seems clumsy :*code is relatively verbose :*more accessible and extensive documentation :If my major focus was statistical then I think R would be the obvious choice. However I find J's data manipulation features to be both simpler and more powerful. So my current have-my-cake-and-eat-it-too solution is to use J for creating and manipulating data, then use its Rserve interface to access features/packages from R as required. However so far my R usage has been "light"." - |u://user173993> :"R is *weird*. It combines error-prone C-like syntax with data structures that are APL-like but not sufficiently* APL-like to have behaviour that is easy to reason about. The scope rules (certainly the scope rules for S) were obviously designed by someone who had a fanatical hatred of compilers and wanted to ensure that the language could never be usefully compiled." ---- }} Category:J (Programming Language) Category:Coding Languages Category:Software Category:Programming Category:Code